<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/common/load_resources.jsp"%>
<script type="text/javascript">
	$('#close').click(function() {
		closeOverlay();
	});
	
	function deleteProductType(id) {
		refreshOverlay("deleteSubmitProductType.do?deleteId=" + id, 'deleteProductTypes.do', 'Deleted Successfully!!')
	}
	var options = { 
	    url : '${action}', 
	    success : function() { 
	        alert('Changes saved!');
	        closeOverlay();
	    }
	};
	$('#productTypeForm').submit(function() { 
	    $(this).ajaxSubmit(options); 
	    return false; 
	});
	
	$(document).ready(function() {
		showOverlay('${title}', '40%', '10%', '35%');
	});
</script>

<div id="overlayContent" css="hidden">
	<form:form action="${action}" method="post" modelAttribute="productTypeForm" id="productTypeForm">
		<form:errors cssClass="form-error-message" path="*"/>
		<table>
		   	<c:forEach items="${productTypeForm.productTypes}" var="productType" varStatus="loop">
		   		<tr><form:hidden path="productTypes[${loop.index}].oid" id="oid"/><form:hidden path="productTypes[${loop.index}].versionStamp"/>
		   			<c:if test="${empty readOnly}">
		        		<td class="formLabel"><label for="name">Name: </label></td>
		        		<td class="formInput"><form:input path="productTypes[${loop.index}].category"/></td>
		        	</c:if>
		        	<c:if test="${not empty readOnly}">
		        		<td class="formLabel"><label for="name">Name: </label></td>
		        		<td class="formInput"><label for="name">${productType.category}</label></td>
		        		<c:if test="${not empty isDelete}">
		        			<td class="formInput"><input type="submit" id="delete" value="  Delete  " onclick="deleteProductType(${productType.oid})"/></td>
		        		</c:if>
		        	</c:if>
		       	</tr>
		   	</c:forEach>
		   	<tr>
		   		<c:if test="${empty readOnly}">
		   			<td class="formLabel"><input type="submit" name="submit" id="submit" value="  Submit  " /></td>
		   		</c:if>
		   		<td class="formInput"><a href="#" id="close">Close</a></td>
		   	</tr>
		</table>
	</form:form>
</div>

</body>
</html>